<template>
  <!-- 添加或修改过卡记录对话框 -->
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="1000px"
    append-to-body
    :close-on-click-modal="false"
    @close="close"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="98px" label-position="right"  class="flex-form" size="small">
          <el-form-item label="采集列号" prop="seqNo">
        <el-input v-model.trim="form.seqNo" placeholder="请输入采集列号" />
      </el-form-item>
    
          <el-form-item label="海关编码" prop="customsCode">
        <el-input v-model.trim="form.customsCode" placeholder="请输入海关编码" />
      </el-form-item>
    
          <el-form-item label="场站编码" prop="fieldCode">
        <el-input v-model.trim="form.fieldCode" placeholder="请输入场站编码" />
      </el-form-item>
    
          <el-form-item label="场站名称" prop="fieldName">
        <el-input v-model.trim="form.fieldName" placeholder="请输入场站名称" />
      </el-form-item>
    
          <el-form-item label="通道编码" prop="channelNo">
        <el-input v-model.trim="form.channelNo" placeholder="请输入通道编码" />
      </el-form-item>
    
          <el-form-item label="通道名称" prop="channelName">
        <el-input v-model.trim="form.channelName" placeholder="请输入通道名称" />
      </el-form-item>
    
          <el-form-item label="进出口标志" prop="iEFlag">
        <el-input v-model.trim="form.iEFlag" placeholder="请输入进出口标志" />
      </el-form-item>
    
          <el-form-item label="进出场" prop="ieType">
        <el-select v-model.trim="form.ieType" placeholder="请选择进出场">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
    
          <el-form-item label="车辆海关编码" prop="veCustomsNo">
        <el-input v-model.trim="form.veCustomsNo" placeholder="请输入车辆海关编码" />
      </el-form-item>
    
          <el-form-item label="车牌号" prop="vehicleNo">
        <el-input v-model.trim="form.vehicleNo" placeholder="请输入车牌号" />
      </el-form-item>
    
          <el-form-item label="车辆自重" prop="emptyWt">
        <el-input v-model.trim="form.emptyWt" placeholder="请输入车辆自重" />
      </el-form-item>
    
          <el-form-item label="挂车重量" prop="trayWt">
        <el-input v-model.trim="form.trayWt" placeholder="请输入挂车重量" />
      </el-form-item>
    
          <el-form-item label="IC卡号" prop="cardNo">
        <el-input v-model.trim="form.cardNo" placeholder="请输入IC卡号" />
      </el-form-item>
    
          <el-form-item label="电子车牌" prop="rfid">
        <el-input v-model.trim="form.rfid" placeholder="请输入电子车牌" />
      </el-form-item>
    
          <el-form-item label="集装箱号" prop="contaNo">
        <el-input v-model.trim="form.contaNo" placeholder="请输入集装箱号" />
      </el-form-item>
    
          <el-form-item label="集装箱重量" prop="contaWt">
        <el-input v-model.trim="form.contaWt" placeholder="请输入集装箱重量" />
      </el-form-item>
    
          <el-form-item label="放行标识" prop="checkResult">
        <el-input v-model.trim="form.checkResult" placeholder="请输入放行标识" />
      </el-form-item>
    
          <el-form-item label="led显示" prop="ledHint">
        <el-input v-model.trim="form.ledHint" type="textarea" placeholder="请输入内容" />
      </el-form-item>
    
          <el-form-item label="批次号" prop="manifestId">
        <el-input v-model.trim="form.manifestId" placeholder="请输入批次号" />
      </el-form-item>
    
          <el-form-item label="报关单号" prop="entryId">
        <el-input v-model.trim="form.entryId" placeholder="请输入报关单号" />
      </el-form-item>
    
          <el-form-item label="单证编号" prop="billCode">
        <el-input v-model.trim="form.billCode" placeholder="请输入单证编号" />
      </el-form-item>
    
          <el-form-item label="业务类型" prop="businessType">
        <el-select v-model.trim="form.businessType" placeholder="请选择业务类型">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
    
          <el-form-item label="过卡类型" prop="veGrossType">
        <el-select v-model.trim="form.veGrossType" placeholder="请选择过卡类型">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
    
          <el-form-item label="过卡重量" prop="crossWeight">
        <el-input v-model.trim="form.crossWeight" placeholder="请输入过卡重量" />
      </el-form-item>
    
          <el-form-item label="货物重量" prop="goodsWt">
        <el-input v-model.trim="form.goodsWt" placeholder="请输入货物重量" />
      </el-form-item>
    
          <el-form-item label="货物名称" prop="goodsName">
        <el-input v-model.trim="form.goodsName" placeholder="请输入货物名称" />
      </el-form-item>
    
          <el-form-item label="放行时间" prop="checkTime">
        <el-date-picker clearable size="small"
                        v-model.trim="form.checkTime"
                        type="date"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="选择放行时间">
        </el-date-picker>
      </el-form-item>
    
          <el-form-item label="验放主体" prop="checkBody">
        <el-input v-model.trim="form.checkBody" placeholder="请输入验放主体" />
      </el-form-item>
    
          <el-form-item label="企业编码" prop="declCopCode">
        <el-input v-model.trim="form.declCopCode" placeholder="请输入企业编码" />
      </el-form-item>
    
          <el-form-item label="企业名称" prop="declCopName">
        <el-input v-model.trim="form.declCopName" placeholder="请输入企业名称" />
      </el-form-item>
    
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="close">取 消</el-button>
      </div>
  </el-dialog>
</template>

<script>
import { getGkHdGather, addGkHdGather, updateGkHdGather } from "@/api/billsdecl/GkHdGather";
export default {
  name: "GkHdGather-addEdit",
  props: {
    dialogType: {
      type: String,
      default: "add",
    },
    rowData: {
      type: Object,
      default: () => {},
    },
    dict:{}
  },
  data() {
    return {
      // 弹出层
      dialogVisible: false,
      // 标题
      title: "新增",
      // 表单参数
      form: {
                                              id: null,
                                                            seqNo: null,
                                                            customsCode: null,
                                                            fieldCode: null,
                                                            fieldName: null,
                                                            channelNo: null,
                                                            channelName: null,
                                                            iEFlag: null,
                                                            ieType: null,
                                                            veCustomsNo: null,
                                                            vehicleNo: null,
                                                            emptyWt: null,
                                                            trayWt: null,
                                                            cardNo: null,
                                                            rfid: null,
                                                            contaNo: null,
                                                            contaWt: null,
                                                            checkResult: null,
                                                            ledHint: null,
                                                            manifestId: null,
                                                            entryId: null,
                                                            billCode: null,
                                                            businessType: null,
                                                            veGrossType: null,
                                                            crossWeight: null,
                                                            goodsWt: null,
                                                            goodsName: null,
                                                            checkTime: null,
                                                            checkBody: null,
                                                            declCopCode: null,
                                                            declCopName: null,
                                                            createTime: null
                        
      },
      // 过卡记录表格数据
      GkHdGatherList: [],
      // 表单校验
      rules: {
      }
    };
  },
  methods: {
    open() {
      this.dialogVisible = true;
      this.$nextTick(() => {
        if (this.dialogType == "add") {
          this.title = "新增";
        } else if (this.dialogType == "edit") {
          this.title = "编辑";
          this.loadDetail();
        } else if (this.dialogType == "detail") {
          this.title = "详情";
          this.loadDetail();
        }
      });
    },
    close() {
      this.$refs["form"].resetFields();
      this.dialogVisible = false;
    },

    // 获取详情
    loadDetail() {
      const id = this.rowData.id;
      getGkHdGather(id).then((res) => {
        if (res.code == 200) {
          this.form = res.data;
                  }
      });
    },

    // 提交表单
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          let params = {
            ...this.form,
          };
          if (this.dialogType == "add") {
            addGkHdGather(this.form).then(res => {
              if (res.code === 200) {
                this.$modal.msgSuccess("新增成功");
                this.close();
                this.$emit("handleQuery");
              }
            });
          } else {
            params.id = this.rowData.id;
            updateGkHdGather(this.form).then(res => {
              if (res.code === 200) {
                this.$modal.msgSuccess("修改成功");
                this.close();
                this.$emit("handleQuery");
              }
            });
          }
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
